Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache fourier sin/cos computation #236

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Cache fourier sin/cos computation #236

wants to merge 2 commits into from

Conversation

maxnoe
Copy link
Member

@maxnoe maxnoe commented Jan 6, 2025

Performance comparison for one event:

Here:

❯ ipython time_fourier.py
[[-0.84497639  0.12606332 -0.41890738 ... -0.04808525 -0.29396779
  -0.9354359 ]
 [ 0.23389281 -0.00328971  1.44855959 ...  0.24069143 -2.06059856
  -0.30701159]]
439 µs ± 693 ns per loop (mean ± std. dev. of 7 runs, 1,000 loops each)

On main:

❯ ipython time_fourier.py
[[-0.84497639  0.12606332 -0.41890738 ... -0.04808525 -0.29396779
  -0.9354359 ]
 [ 0.23389281 -0.00328971  1.44855959 ...  0.24069143 -2.06059856
  -0.30701159]]
940 µs ± 5.6 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)

Script:

from ctapipe_io_lst import LSTEventSource
from pathlib import Path
from traitlets.config import Config


test_data = Path('test_data').absolute()
test_r0_path = test_data / 'real/R0/20200218/LST-1.1.Run02008.0000_first50.fits.fz'
calib_version = "ctapipe-v0.17"
calib_path = test_data / 'real/monitoring/PixelCalibration/Cat-A/'
test_time_calib_path = calib_path / f'drs4_time_sampling_from_FF/20191124/{calib_version}/time_calibration.Run01625.0000.h5'
test_calib_path = calib_path / f'calibration/20200218/{calib_version}/calibration_filters_52.Run02006.0000.h5'
test_drs4_pedestal_path = calib_path / f'drs4_baseline/20200218/{calib_version}/drs4_pedestal.Run02005.0000.h5'


config = Config({
    'LSTEventSource': {
        'pointing_information': False,
        'trigger_information': False,
        'LSTR0Corrections': {
            'drs4_pedestal_path': test_drs4_pedestal_path,
            'drs4_time_calibration_path': test_time_calib_path,
            'calibration_path': test_calib_path,
        },
    },
})

source = LSTEventSource(
    input_url=test_r0_path,
    config=config,
)

with source:
    event = next(iter(source))

tel_id = 1


def compute_timeshift():
    return source.r0_r1_calibrator.get_drs4_time_correction(
        tel_id, source.r0_r1_calibrator.first_cap[tel_id],
        selected_gain_channel=event.r1.tel[tel_id].selected_gain_channel,
    )

print(compute_timeshift())

result = get_ipython().run_line_magic("timeit", "compute_timeshift()")

Run with ipython time_fourier.py

Copy link

codecov bot commented Jan 6, 2025

Codecov Report

Attention: Patch coverage is 31.81818% with 15 lines in your changes missing coverage. Please review.

Project coverage is 90.68%. Comparing base (247104c) to head (4a24199).

Files with missing lines Patch % Lines
src/ctapipe_io_lst/calibration.py 31.81% 15 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #236      +/-   ##
==========================================
- Coverage   90.97%   90.68%   -0.29%     
==========================================
  Files          25       25              
  Lines        2637     2652      +15     
==========================================
+ Hits         2399     2405       +6     
- Misses        238      247       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@moralejo moralejo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants